package com.ztf.task;
import java.util.HashMap;
import java.util.Map;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.junit.Test;

public class Task2Test {
    @Test
    public void testDeploy(){
        ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
        processEngine.getRepositoryService()
                .createDeployment()
                .addClasspathResource("com/itheima09/activiti5/task/task2.bpmn")
                .deploy();
    }

    @Test
    public void testStartPi(){
        Map<String, Object> variables = new HashMap<String, Object>();
        /**
         * 通过流程变量的形式给
         *     <userTask id="请假申请" name="请假申请" activiti:assignee="#{applicator}"></userTask>
         *     中的applicator赋值
         *    必须在进入该userTask节点之前给applicator赋值
         */
        variables.put("applicator", "张三");
        ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
        processEngine.getRuntimeService()
                .startProcessInstanceById("task2:1:2404",variables);
    }

    @Test
    public void testFinishTask(){
        ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
        processEngine.getTaskService()
                .complete("2505");
    }
}

